*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: FIGURE G3 (Online Appendix)

***************************

cd ""

use "DTA files/Dataset", clear

xtset id_cross_section year
global horizon1 6
global horizon2 6

drop if percent4 == .
matrix mat = J($horizon1+$horizon2-1,2,.)

sum percent4, detail
local p50 = r(p50)

gen concentrated = 1 if percent4 > `p50'
replace concentrated = 0 if concentrated == .

collapse (sum) H_EMP va (mean) PCPI EPLregularworkers, by(year ifscode concentrated)

gen VA_QI = H_EMP

egen id_cross_section = group(ifscode concentrated)

forvalues a = 0/0 {
* Fill matrix
capture drop v1 v2 v3 v4 var_colnames 
xtset id_cross_section year
forvalues i = 2/$horizon1 {

gen VA_QI`i'= 100*(VA_QI[_n+1-`i']-VA_QI[_n])/VA_QI if id_cross_section==id_cross_section[_n-`i']

sum VA_QI`i' if EPLregularworkers==1  & concentrated == 1, detail  /* change during positive reform */ 
local sc1 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==1  & concentrated == 0, detail  /* change during positive reform */ 
local sc10 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==0  & concentrated == 1, detail /* change in non-reforming years */ 
local sc2 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==0  & concentrated == 0, detail  /* change during positive reform */ 
local sc20 = r(mean)
matrix mat[$horizon1+1-`i',1] = `sc1'-`sc10'
matrix mat[$horizon1+1-`i',2] = `sc2'-`sc20'
} 

forvalues i = 1/$horizon2 {

capture drop VA_QI`i'
gen VA_QI`i' = 100*(f`i'.VA_QI-VA_QI)/VA_QI

quietly sum VA_QI`i' if EPLregularworkers==1 & concentrated == 1, detail
local sc1 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==1 & concentrated == 0, detail
local sc10 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==0 & concentrated == 1, detail
local sc2 = r(mean)
quietly sum VA_QI`i' if EPLregularworkers==0 & concentrated == 0, detail
local sc20 = r(mean)
matrix mat[$horizon1+`i'-1,1] = `sc1'-`sc10'
matrix mat[$horizon1+`i'-1,2] = `sc2'-`sc20'
} 

svmat mat
}

gen time = _n
replace time = . if time > 11
replace time = time - 6

* Line graph
graph twoway line mat1 mat2 time, xsize(10) ysize(5) lwidth(thick thick) lpattern(solid dash) lcolor(green red)  xline(0,lcolor(black) ) yline(0, lcolor(black)) ylabel(, grid) graphregion(color(white)) ytitle("") xlab(-5(1)5) xtitle("") legend(label(1 "Reform observations") label(2 "Status quo observations") size(medlarge)) 
graph export "Figures/G3.png", replace
